package cn.tedu;

import cn.tedu.dao.userInfoMapper;
import cn.tedu.pojo.userInfo;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class test {
    @Test
    public void Test1() throws IOException {
        InputStream resourceAsStream = Resources.getResourceAsStream("userInfo_config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        SqlSession sqlSession = sqlSessionFactory.openSession(true);
        /**true表示自动提交*/
        userInfoMapper mapper = sqlSession.getMapper(userInfoMapper.class);
        List<userInfo> all = mapper.getAll();
        List<userInfo> all1 = mapper.getAll();
        for (userInfo userInfo : all) {
            System.out.println(userInfo);
        }
        for (userInfo userInfo : all1) {
            System.out.println(userInfo);
        }
    }
}
